const js = require('@eslint/js')
const globals = require('globals')
const eslintParser = require('@babel/eslint-parser')
const eslintPretterPlugin = require('eslint-plugin-prettier')

module.exports = [
	// 忽略文件配置
	{
		ignores: ['node_modules/', 'dist/', 'test/', '*.min.js']
	},
	// 基础 JavaScript 配置
	{
		files: ['**/*.js'],
		languageOptions: {
			ecmaVersion: 'latest',
			sourceType: 'module',
			parser: eslintParser,
			parserOptions: {
				requireConfigFile: false,
				babelOptions: {
					babelrc: false,
					configFile: false,
					presets: ['@babel/preset-env']
				}
			},
			globals: { ...globals.browser, ...globals.node }
		},
		plugins: {
			prettier: eslintPretterPlugin
		},
		rules: {
			...js.configs.recommended.rules,
			'prettier/prettier': [
				'error',
				{
					singleQuote: true,
					semi: false
				}
			],
			'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
			'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
		}
	}
]
